<?php

class TributePackages extends Zend_Db_Table_Abstract
{
    protected $_name = 'tributes';
	
	public static $_tributes = array(
		"Basic Burial Tribute",
		"Select Burial Tribute",
		"Traditional Burial Tribute",
		"Basic Cremation Tribute",
		"Select Cremation Tribute",
		"Traditional Cremation Tribute",
		"Basic Memorial Tribute",
		"Select Memorial Tribute",
		"Traditional Memorial Tribute"
	);
	
	public function getBulletPointsForTribute( $tribute_name )
	{
		$results = array();
		
		if(empty($tribute_name))
		{
			$results['status'] = "FAILED_BAD_PARAM";
			return $results;	
		}
		
		try
		{
			$fetchedRow = $this->fetchRow("tribute_name='$tribute_name'");
			if($fetchedRow)
				$row = $fetchedRow->toArray();
			else
				$row = array();
			$results['status'] = "SUCCEEDED";
			$results['rows'] = array( $row );	
		}
		catch(Exception $e)
		{
			$results['status'] = "FAILED";
			$results['rows'] = array();	
		}
		
		return $results;
	}

	public function setBulletPointsForTribute( $bpXML, $tribute_name )
	{
		$results = array();
		
		if(empty($tribute_name))
		{
			$results['status'] = "FAILED_BAD_PARAM";
			return $results;	
		}
		
		if(empty($bpXML))
		{
			$results['status'] = "FAILED_BAD_PARAM";
			return $results;	
		}
		
		try
		{
			$this->delete("tribute_name='$tribute_name'");
			
			$data = array(
					"tribute_name"=>$tribute_name,
					"bigxml"=>$bpXML
					);
						
			$affectedRows = $this->insert($data);
			$results['status'] = "SUCCEEDED";
			$results['affected_rows'] = $affectedRows;	
		}
		catch(Exception $e)
		{
			$results['status'] = "FAILED";
			$results['affected_rows'] = 0;	
		}
	}
}

?>
